package cn.unknownerror.ueteam.gui;

import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;

public abstract class DynamicFrame<T> extends AbstractFrame{

    public DynamicFrame(int size,String title){
        super(size,title);
    }

    public Inventory createInventory(T t) {
        Inventory inv= Bukkit.createInventory(null,size,identify+getTitle(t));
        for (int i = 0; i < buttons.length; i++) {
            AbstractButton button=buttons[i];
            if(button==null){
                continue;
            }
            if(button instanceof DynamicButton){
                inv.setItem(i,((DynamicButton<T>)button).onCreate(t));
                continue;
            }
            inv.setItem(i,button.getItem());
        }
        return inv;
    }

    public String getTitle(T t){
        return super.title;
    }

}
